FUNCTION z_get_report_result.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(I_REPORTNAME) LIKE  SY-REPID
*"  TABLES
*"      LISTOUT STRUCTURE  TAB512
*"  EXCEPTIONS
*"      REPORT_NICHT_GEFUNDEN
*"      ERROR_LIST_FROM_MEMORY
*"----------------------------------------------------------------------

  TABLES trdir.

  SELECT SINGLE * FROM trdir WHERE name = i_reportname.

  IF sy-dbcnt NE 1.
    RAISE report_nicht_gefunden.
  ENDIF.

  SUBMIT (i_reportname) EXPORTING LIST TO MEMORY AND RETURN.

  DATA list LIKE abaplist OCCURS 0.
  DATA plainlist LIKE tab512 OCCURS 0 WITH HEADER LINE.


  CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
      listobject       = list
* EXCEPTIONS
*   NOT_FOUND        = 1
*   OTHERS           = 2
            .
  IF sy-subrc <> 0.
    RAISE error_list_from_memory.
  ENDIF.

  CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
      listasci                 = listout
      listobject               = list
* EXCEPTIONS
*   EMPTY_LIST               = 1
*   LIST_INDEX_INVALID       = 2
*   OTHERS                   = 3
            .
  IF sy-subrc <> 0.
    RAISE error_list_to_asci.
  ENDIF.

*loop at plainlist.
*  write / plainlist.

*  CALL FUNCTION 'WRITE_LIST'
*    TABLES
*      listobject       = list
*  EXCEPTIONS
*    EMPTY_LIST       = 1
*    OTHERS           = 2
  .
*  IF sy-subrc <> 0.
*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*  ENDIF.
* endloop.




ENDFUNCTION.